<template>
  <div>
    <h2>物流相关信息</h2>
    <div class="logistics-info-header">
      <div class="logistics-info-header-left">
        <div ref="color" class="logistics-status blue">{{ nowStatus }}</div>
        <div class="logistics-company">顺丰速运</div>
        <div class="logistics-no">SF123456789</div>
      </div>
    </div>
    <ul class="logistics-info-list">
      <li v-for="item in orderInfo.logisticsInfo" :key="item.time">
        <div class="logistics-info-list-time">{{ item.time }}</div>
        <div class="logistics-info-list-content">{{ item.content }}</div>
      </li>
    </ul>
    <button v-role='orderInfo.role' :disabled='true'>查看物流详情</button>
  </div>
</template>

<script>
export default {
  name: 'MyList',
  props: {
    orderInfo: Object,
  },
  components: {},
  data() {
    return {}
  },
  directives:{
    role:{
      inserted(el,{value}){
       const res=['admin','zhangsan','admin'].includes(value)
      el.disabled=!res
      }
    }
  },

  computed: {
    nowStatus() {
    //   if (this.orderInfo.logisticsStatus === 2) {
    //     // this.$nextTick(()=>{
    //     //   console.log(this);
    //     //   this.$refs.color.style.color='red'
        
    //      Promise.resolve(this.$refs.color).then(console.log
          
    // )

    //     // })
    //     return '已签收'
    //   }
      const status = this.orderInfo.logisticsStatus

      const fn = (a) => {
        this.$nextTick(() => {
          this.$refs.color.style.color = a
        })
      }

      if (status === 0) {
        fn('red')
        return '未发货'
      } else if (status === 1) {
        fn('blue')
        return '已发货'
      } else if (status === 2) {
        fn('green')
        return '已签收'
      } else {
        fn('yellow')
        return '未签收'
      }
    },
  },
}
</script>

<style scoped lang="less"></style>
